<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
    <form method="post">
        <textarea name="input"></textarea>
        <input type="submit" value="Count words" />
    </form>
    <?php
    if (isset($_POST['input'])) {
        $inputText = $_POST['input'];
        $words = preg_split("/\W+/", $inputText, 0, PREG_SPLIT_NO_EMPTY);

        $wordsCount = array();

        foreach ($words as $word) {
            if ($wordsCount[strtolower($word)]) {
                $wordsCount[strtolower($word)]++;
            }
            else {
                $wordsCount[strtolower($word)] = 1;
            }
        }

        $resultTable = '<table>';
        
        foreach ($wordsCount as $key => $value) {
            $resultTable .= "<tr><td>$key</td><td>$value</td></tr>";
        }

        $resultTable .= '</table>';

        echo $resultTable;
    }
    ?>
</body>
</html>